<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <button id="but">按钮</button>
    <script>
        var but = document.querySelector("#but");
        but.addEventListener("click",fn);
        but.addEventListener("dblclick",fn1);
        var demo;
        function fn (){
           clearTimeout(demo)
            demo = setTimeout(function(){
                alert(123)
            },400)
          
        }
        function fn1(){
            clearTimeout(demo)
            alert(456)
            
        }
    
    </script>
</body>
</html>